const Mock = require('mockjs');

/**
 * 法律服务产品
 */

function getServiceProductList () {
  const { Random } = Mock;
  let list = [];
  let randomNumber = Math.ceil(Math.random() * 10);
  for (let i = 0; i < randomNumber; i++) {
    let item =  Mock.mock({
      'ProductGuid': Random.guid(),
      'ServiceName': Random.cword(7),
      'PictureUrl|1': [
        `${Random.url('https')}/${Random.last()}.jpg`,
        `${Random.url('https')}/${Random.last()}.png`,
        `${Random.url('https')}/${Random.last()}.jpeg`
      ]
    });
    list.push(item);
  }
 return list;
}

function getServiceProductDetail (productGuid) {
  const { Random } = Mock;
  return Mock.mock({
    'ProductGuid': productGuid,
    'ServiceName': Random.cword(7),
    'PictureUrl|+1': [
      `${Random.url('https')}/${Random.last()}.jpg`,
      `${Random.url('https')}/${Random.last()}.png`,
      `${Random.url('https')}/${Random.last()}.jpeg`
    ],
    'AudioUrl': Random.url('https'),
    'Detail|1': [
      `<p>${Random.paragraph()}</p>`,
      `<p>${Random.paragraph(1, 3)}</p>`,
      `<p>${Mock.mock('@paragraph(1, 3)')}</p>`,
    ]
  })
}

module.exports = { 
  getServiceProductList,
  getServiceProductDetail
};